package com.project.restaurant.common.dao;

import com.project.restaurant.common.dto.BriefRestaurant;
import com.project.restaurant.common.typehandler.RestaurantStateTypeHandler;
import org.apache.ibatis.annotations.*;

@Mapper
public interface BriefRestaurantDao {

    @Results(id = "BriefRestaurantResultMap",value = {
            @Result(column = "restaurant_id",property = "restaurantId"),
            @Result(property = "restaurantPicture",
                    many = @Many(resultMap = "com.project.restaurant.mapper.RestaurantPictureMapper.RestaurantPictureResultMap")),
            @Result(column = "restaurant_state",property = "restaurantState",
                    typeHandler = RestaurantStateTypeHandler.class)
    })

    @Select("select r.restaurant_id,r.restaurant_name,r.restaurant_phone,r.restaurant_state,rp.restaurant_picture_url " +
            "from " +
            "restaurant r join r_restaurant_picture rp " +
            "on r.restaurant_id = rp.restaurant_id")
    BriefRestaurant defaultSelect();
}
